<template>
  <div class="tab">
    <div
      class="tabItem"
      v-for="(item, index) in tabItem"
      @click="getActive(index)">
      <span :class="{ active: index == currentIndex }">{{ item }}</span>
    </div>
  </div>
</template>

<script>
export default {
  name: "Goods",
  components: {},
  props: {
    tabItem:{
      type:Array,
      default:{}
    }
  },
  data() {
    return {
      currentIndex: 0,
    };
  },
  mounted() {},
  methods: {
    getActive(index) {
      this.currentIndex = index;
      this.$emit('itemClick', index);
    },
  },
};
</script>

<style lang="css" scoped>
.tab {
  display: flex;
  height: 40px;
  line-height: 40px;
  flex-direction: row;
  background-color: #fff;
  z-index: 9;
}
.tabItem {
  flex: 1;
  text-align: center;
}
.active {
  margin: 0 5px 0 5px;
  border-bottom: 2px salmon solid;
}
</style>